package com.buanalintas.sandals.pos.size;

import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.sandals.pos.entities.PosMasterSize;

public class Size extends Page {

    private Field sizeId;
    private Field sizeCode;
    private Field sizeName;

    public Size() {
        setTheClass(PosMasterSize.class);

        sizeId = new Field();
        sizeId.setName("sizeId");
        sizeId.setCaption("id");
        sizeId.setListProperties(" align=\"right\" width=\"10%\" nowrap");
        sizeId.setInputProperties(" size=\"20\"");
        getFields().add(sizeId);

        sizeCode = new Field();
        sizeCode.setName("sizeCode");
        sizeCode.setCaption("code");
        sizeCode.setListProperties(" align=\"center\" width=\"10%\" nowrap");
        sizeCode.setInputProperties(" size=\"30\"");
        sizeCode.setRequired(true);
        getFields().add(sizeCode);

        sizeName = new Field();
        sizeName.setName("sizeName");
        sizeName.setCaption("size");
        sizeName.setListProperties(" align=\"right\" width=\"80%\" nowrap");
        sizeName.setInputProperties(" size=\"30\"");
        sizeName.setRequired(true);
        getFields().add(sizeName);

        fillFields();
        
        getFieldsUnique().add(new Field[]{sizeName});
        getFieldsAdd().remove(sizeId);
        getFieldsEdit().remove(sizeId);
        getFieldsList().remove(sizeId);
        
        setExportList(getClass().getResourceAsStream("SizeList.jasper"));
        setExport(getClass().getResourceAsStream("Size.jasper"));
        getController().setOrder(sizeName);
    }

    @Override
    public void beforeView() {
        beforeList();
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "Size"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();

    }
}
